﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WAU.DTOs.UserDailyActivityModule;
using WAU.Models.Framework;
using WAU.Services;

namespace WAU.Controllers
{
    /// <summary>
    /// 用户日常活动的控制器，如 签到 等
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserDailyActivityController : EssentialController
    {
        /// <summary>
        /// Service
        /// </summary>
        private readonly UserDailyActivityService _service;

        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="service"></param>
        public UserDailyActivityController(UserDailyActivityService service)
        {
            this._service = service;
        }

        /// <summary>
        /// 用户日常签到
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [Authorize]
        public async Task<ActionResult> DailySign(DailySignDto dto)
        {
            ExecResult<int> result = await _service.DailySign(CurrentUserId, dto);
            return Ok(new Result
            {
                Success = result.Success,
                Data = result.Data,
                Msg = result.ErrorMsg
            });
        }

        /// <summary>
        /// 用户补签
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        [Authorize]
        public async Task<ActionResult> SupplyDailySign(DailySignDto dto)
        {
            ExecResult<int> result = await _service.SupplyDailySign(CurrentUserId, dto);
            return Ok(new Result
            {
                Success = result.Success,
                Data = result.Data,
                Msg = result.ErrorMsg
            });
        }
    }
}
